<template>
  <div class="contact-us">
    <div class="name">
      <h1>联系我们</h1>
      <h3>contact-us</h3>
    </div>
    <div :class="CompanyList.length < 4 ? 'box-wrap-flex' : 'box-wrap-grid'">
      <el-card class="box-card" v-for="(item, index) in CompanyList" :key="index">
        <template #header>
          <div class="card-header">
            <span>{{ item.CompanyName }}</span>
            <!-- <span class="button" text>南山区</span> -->
          </div>
        </template>
        <div class="box-bottom">
          <div>
            <div class="text item">
              <span>[网址]</span>
              <el-link type="primary" @click="openUrl(item.CompanyNetWork)">{{ item.CompanyNetWork }}</el-link>
            </div>
            <div class="text item">
              <span>[电话]</span>
              {{ item.Phone }}
            </div>
            <div class="text item">
              <span>[地址]</span>
              {{ item.Address }}
            </div>
          </div>
          <div>
            <el-image style="width: 100px; height: 100px" :src="item.WechatQRCode" fit="fill" />
          </div>
        </div>
      </el-card>
    </div>
  </div>
  
</template>

<script>
import { connrequest } from '@/api/firstPage'
export default {
  name: 'contactUs',
  data() {
    return {
      CompanyList: [],
    };
  },
  created(){
    this.getData()
  },
  methods: {
    async getData(){
      try {
        const res = await connrequest('GetContactUS')
        this.CompanyList = res.Data
      } catch (error) {
        console.log(error);
      }
    },
    openUrl(url){
      window.open(url)
    },
    copyAnswer(data){
      let elInput = document.createElement('textarea')
      elInput.value = data
      document.body.appendChild(elInput)
      // 选择对象
      elInput.select()
      // 执行浏览器复制命令
      this.$message.success('复制成功')
      document.execCommand("Copy")
      elInput.remove()
    },
    async translate() {
      
    },
  },
};
</script>

<style lang="scss" scoped>
.contact-us{
  width:calc(100vw - 230px);
  height: calc(100vh - 70px);
  overflow-y: auto;
  background: #fff;
  padding: 20px;
  margin: 10px;
  h1{
    margin: 0;
  }
  h3{
    margin: 0 0 40px;
  }
  .name{
    text-align: center;
  }
  .box-wrap-grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 10px;
  }
  .box-wrap-flex{
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
  }
  .box-wrap-flex > *{
    margin-right: 10px;
  }
  .box-card{
    width: 380px;
    .card-header {
      font-weight: bold;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .box-bottom{
      display: flex;
      justify-content: space-between;
      align-items: center;
      .text {
        font-size: 14px;
        text-align: left;
        span{
          display: block;
          font-weight: bold;
          padding: 5px 0px;
        }
      }
    }
    
  }
}
</style>
